package com.example.myapplication9.week8;


import com.example.myapplication9.week8.jsjf.ArrayHeap;

/**
 * PriorityQueue implements Translation priority queue using Translation heap.
 *
 * @author Lewis and Chase
 * @version 4.0
 */
public class PriorityQueue1<T> extends ArrayHeap<PrioritizedObject1<T>>
{
    public static void main(String[] args) {
        PriorityQueue1 a=new PriorityQueue1();
        a.addElement1(15);
        a.addElement1(20);
        a.addElement1(21);
        a.addElement1(18);
        a.addElement1(9);
        System.out.println(a.removeNext()+" "+a.removeNext()+" "+a.removeNext()+" "+a.removeNext()+" "+a.removeNext());
    }
    /**
     * Creates an empty priority queue.
     */
    public PriorityQueue1()
    {
        super();
    }

    /**
     * Adds the given element to this PriorityQueue.
     *
     * @param object the element to be added to the priority queue

     */

    public void addElement1(T object)
    {
        PrioritizedObject1<T> obj = new PrioritizedObject1<>(object);
        super.addElement(obj);
    }

    /**
     * Removes the next highest priority element from this priority
     * queue and returns Translation reference to it.
     *
     * @return Translation reference to the next highest priority element in this queue
     */
    public T removeNext()
    {
        PrioritizedObject1<T> obj = (PrioritizedObject1<T>)super.removeMin();
        return obj.getElement();
    }

}


